import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import Layout from '@/layout'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
      name: 'login',
      component: () => import('@/views/Login.vue')
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: '/home',
      name: 'home',
      component: HomeView,
      meta: { title: '首页', access: 0, affix: true }
    }]
  },
  {
    path: '/dashboard',
    component: Layout,
    children: [{
      path: "/dashboard",
      name: 'DashBoard',
      component: () => import('@/views/DashBoard.vue'),
      meta: { title: '数据仪表盘', access: 0 }
    }]
  },
  {
    path: '/system',
    component: Layout,
    redirect: '/system/user',
    meta: { title: '人员管理' },
    children: [{
      path: '/system/user',
      name: 'user',
      component: () => import('@/views/User.vue'),
      meta: { title: '用户', access: 0, affix: true }
    },{
      path: '/system/role',
      name: 'role',
      component: () => import('@/views/Role.vue'),
      meta: { title: '角色', access: 0, affix: true }
    }
   ]
  },
  {
    path: '/room',
    component: Layout,
    redirect: '/room/category',
    meta: { title: '房间管理' },
    children: [{
      path: '/room/category',
      name: 'category',
      component: () => import('@/views/Category.vue'),
      meta: { title: '类别', access: 0, affix: true }
    },{
      path: '/room/item',
      name: 'item',
      component: () => import('@/views/Room.vue'),
      meta: { title: '房间', access: 0, affix: true }
    }
   ]
  },
  {
    path: '/sale',
    component: Layout,
    redirect: '/sale/order',
    meta: { title: '入住管理' },
    children: [{
      path: '/sale/order',
      name: 'Sale',
      component: () => import('@/views/Sale.vue'),
      meta: { title: '订单', access: 0 }
    },{
      path: '/sale/checkin',
      name: 'CheckIn',
      component: () => import('@/views/CheckIn.vue'),
      meta: { title: '入住', access: 0 }
    }]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
